import Model from "../../common/model/Model";
import BaseUi from "../base/BaseUi";

const {ccclass, property} = cc._decorator;

@ccclass
export default class GamePlayerUi extends BaseUi {

    @property(cc.Label)
    nickname: cc.Label = null;

    private index:number = -1;
    // onLoad () {}

    start () {

    }
    /** 设置玩家index */
    setPlayerIndex(index:number) {
        this.index = index;
        this.modelEvent("model.room.player", this.refreshUsername.bind(this));
    }
    private refreshUsername() {
        
        if (Model.model.room && Model.model.room.player[this.index]) {
            this.nickname.string = "有人";
        } else {
            this.nickname.string = "没人";
        }
    }
}
